<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
@html_name: 10生成器实例
@description: The past cannot be redeemed, the future can be changed.
@author: Jason Black
@create: 2023/6/25 18:15:10
-->
<script>
    function one() {
        setTimeout(() => {
            console.log("001")
            iter_.next()
        }, 1000)
    }

    function two() {
        setTimeout(() => {
            console.log("002")
            iter_.next()
        }, 2000)
    }

    function three() {
        setTimeout(() => {
            console.log("003")
            iter_.next()
        }, 3000)
    }

    function * iter() {
        yield one();
        yield two();
        yield three();
    }

    let iter_ = iter()
    iter_.next()
</script>
</body>
</html>